package com.baosight.sczx.zm.cl.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.cc.Qualitystandard;
import com.baosight.sczx.common.zm.cInterface.cc._5ExamineClassify;
import com.baosight.sczx.common.zm.cInterface.cl.RoundCheckWorkNote;
import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.sczx.common.zm.cInterface.cs.WorkSchedule;
import com.baosight.sczx.zm.cl.domain.ZMCLOperationHistory;
import com.baosight.sczx.zm.cl.domain.ZMCLTernateRecord;

/**
 * <p>Title: ServiceZMCL63.java</p>
 * <p>Description: 三违处理：已处理的服务类</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author  高强
 * @version 1.0
 * <pre>Histroy:
 *           2011-4-18       高强  Create
 *</pre>
 */
public class ServiceZMCL62 extends ServiceEPBase {
	/**
	 * <p>Function: initLoad</p>
	 * <p>Description: 当前页面托管加载初始化操作</p>
	 * <p>return value: initLoad</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-18       高强
	 * </p>
	 *
	*/
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");
		EiInfo outInfo = this.query(inInfo);
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cl.classify", true));//三违分类
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cl.sourceClassify", true));//三违来源
		outInfo.addBlock(Department.getInstance().getConstructionUnit("cmes.cl.department", "orgCode", "orgName", true));//三违单位
		outInfo.addBlock(WorkSchedule.getWorkScheduleBlock("cmes.cl.workNum", false));//三违班次
		outInfo.addBlock(RoundCheckWorkNote.getAllNoteCode("cmes.cl.workNote", true));//巡检工单
		//outInfo.addBlock(WorkingFace.getAllWorkingFace("cmes.cl.workFace", true));//所在工作面
		//outInfo.addBlock(RoadWay.getAllRoadWay("cmes.cl.roadWay", true));//所在巷道
		outInfo.addBlock(Qualitystandard.getQualityStandardItems("cmes.cl.quality", "在用", true));//质量标准化分类
		outInfo.addBlock(_5ExamineClassify.get5examineClassify("cmes.cl.examine", "在用", true));//五个到位分类
		return outInfo;
	}
	
	/**
	 * <p>Function: query</p>
	 * <p>Description: 查询已处理三违信息</p>
	 * <p>return value: EiInfo</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *   2011-6-22       高强
	 * </p>
	 *
	*/
	@Override
	public EiInfo query(EiInfo inInfo) {
		if(inInfo.getBlock(EiConstant.queryBlock) == null){
			StaticTools.setQueryParameters(inInfo, "fdEndDate", StaticTools.getDate(), true);//截止日期
		}
		StaticTools.setQueryParameters(inInfo, "isHandled", "yes", true);
		//StaticTools.setQueryParameters(inInfo, "fdManageDepartmentId",UserSession.getInSessionProperty("orgCode").toString(), true);//查询所有安全管理单位下处理的三违记录
		EiInfo outInfo = super.query(inInfo, "ZMCLTernateRecord.query", new ZMCLTernateRecord());
		return outInfo;
	}
	
	/**查询操作历史明细
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: EiInfo</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-06-20 下午14:49:43  高强
	 * </p>
	 *
	*/
	public EiInfo queryOperationHistory(EiInfo inInfo) 
	{
		String fdRecordId = inInfo.getString("fdRecordId");
		StaticTools.setQueryParameters(inInfo, "fdRecordId", fdRecordId, true);//添加查询条件
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		EiInfo outInfo = super.query(inInfo, "ZMCLOperationHistory.query", new ZMCLOperationHistory());

		return outInfo;

	}
		
}
